package com.dc.chat.app.service.mp;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dc.chat.entity.dao.User;
import org.springframework.stereotype.Service;

@Service
public class UserService extends ServiceImpl<UserService.UserMapper,User> {
    public User selectByUserName(String username) {
        LambdaQueryWrapper<User> wrapper = Wrappers.lambdaQuery(new User());
        wrapper.eq(User::getUserName,username);
        wrapper.last("limit 1");
        return baseMapper.selectOne(wrapper);
    }

    public User selectByUserNameAndPassword(String username, String password) {
        LambdaQueryWrapper<User> wrapper = Wrappers.lambdaQuery(new User());
        wrapper.eq(User::getUserName,username);
        wrapper.eq(User::getPassword,password);
        wrapper.last("limit 1");
        return baseMapper.selectOne(wrapper);
    }

    public interface UserMapper extends BaseMapper<User> {

    }
}
